	_helo = _this select 0;
	_airport = _this select 4;
	_egress = _this select 5;
	_ingress = _this select 6;
	_home = _this select 3;
	_callsign = _this select 1;

	_pilot = driver _helo;
	_gunner = gunner _helo;
	_grp = group _pilot;

	_mkrname = format ["%1station",_helo];
	deletemarkerLocal _mkrname;
	_mkrname2 = format ["%1station2",_helo];
	deletemarkerLocal _mkrname2;

	["RTB",[player,_pilot,_callsign]] execVM (RUM_PATH+"AHel\radiodialogs.sqf");
	sleep 8;

	// spawn a loop to monitor the helo if its still alive or has been destroyed
	_helo spawn {
		_helo = _this select 0;
		_vehchk = true;
		while {_vehchk} do {
			If (!alive _helo) then {
				player sidechat format ["%1 has crashed or has been destroyed.", _callsign];
				hintsilent format ["%1 has crashed or has been destroyed.", _callsign];
				_vehchk = false;
				exit;	
			}else{
				sleep .05;
			};
		};
	};
	
	_wp=_grp addWaypoint [getpos _ingress, 0];
	_wp setWaypointType "MOVE";
	_wp setWaypointSpeed "LIMITED";
	_wp setWaypointBehaviour "CARELESS";
	_wp setWaypointCombatMode "BLUE";
	_wp setWaypointCompletionRadius 50;
	_helo flyInheight 32;
	sleep 4.75;
	deleteWaypoint [_grp, 0];

	_wp=_grp addWaypoint [getpos _ingress, 0];
	_wp setWaypointType "MOVE";
	_wp setWaypointSpeed "NORMAL";
	_wp setWaypointBehaviour "CARELESS";
	_wp setWaypointCombatMode "BLUE";
	_wp setWaypointCompletionRadius 50;
	_grp setcurrentWaypoint _wp;
	_helo flyInheight RUM_AHEL_flyHeight;

	sleep 1;
	if (surfaceIsWater (getpos _home)) then {
		// player sidechat format["Heli is on LHD or Ship, %1",_heliRoute];

		_heloRTBWaypoint = true;
		
		while {_heloRTBWaypoint} do {
			sleep .05;
			_distanceToIngress = round(_ingress distance _helo);
			// hintsilent format["distance from home plate: %1",_distanceToIngress];
			if (_distanceToIngress <=160) then {
				_lz = createVehicle ["HeliHEmpty", getposASL _home, [], 0, "NONE"];
				_lz setposASL getPosASL _home;
				_wp=_grp addWaypoint [getposASL _lz, 0];
				_wp setWaypointType "GETOUT";
				_wp setWaypointSpeed "LIMITED";
				_wp setWaypointBehaviour "CARELESS";
				_wp setWaypointCombatMode "BLUE";
				_wp setWaypointCompletionRadius 0;
				_helo flyInheight (RUM_AHEL_flyHeight -35);
				_stg = "RUM_AHel_endflight = '"+(format ["%1",_helo])+"'";
				_wp setWaypointStatements ["true", _stg];
				// _lz;
				
				// ends the while loop
				_heloRTBWaypoint = false;
			};
		};
		
		// starts new while loop for landing procedures...
		_heloRTBWaypointH = true;
		
		while {_heloRTBWaypointH} do {
			sleep .05;
			_distanceToDeck = round(getposASL _helo select 2);
			_heightToHomePlate = round((getposASL _helo select 2) - (getposASL _home select 2));
			_distToHomePlate = round( _helo distance _home);
			if (_distToHomePlate <= 70) then {
				if (_heightToHomePlate <= 0.5) then {
				sleep 3;
				_helo setFuel 0;
				sleep 5;

				// ends the while loop.
				_heloRTBWaypointH = false;
				}else{
					// hintsilent format ["Height Above Home Plate: %1",_heightToHomePlate];
				};
			}else{
				// hintsilent format ["Distance to Home Plate: %1",_distToHomePlate];
			};
		};
	}else{

		// This section of the if statment is for land based helo's
		// player sidechat format["Heli is not over water, %1",_heliRoute];
		// waits till closer to ingress position before moving to final approach.
		waituntil{((_ingress distance [getPos _helo select 0, getPos _helo select 1, 0]) <= 200)};

		_wp=_grp addWaypoint [getpos _home, 0];
		_wp setWaypointType "GETOUT";
		_wp setWaypointSpeed "NORMAL";
		_wp setWaypointBehaviour "CARELESS";
		_wp setWaypointCombatMode "BLUE";
		_wp setWaypointCompletionRadius 50;
		_helo flyInheight (RUM_AHEL_flyHeight - 45);
		_stg = "RUM_AHel_endflight = '"+(format ["%1",_helo])+"'";
		_wp setWaypointStatements ["true", _stg];

	};
	_end = format ["%1",_helo];
	sleep 5;
	waitUntil{(!alive _helo) OR (RUM_AHel_endflight == _end)};

	// crew members will exit vehicle
	{unassignVehicle _x;_x action ["GETOUT",_helo];} forEach units _grp2;
	// wait till player(s) have exited the vehicle
	player sidechat "Exit the vehicle";
	sleep 10;
	waitUntil{(!alive _helo) OR (count(crew _helo) == 0)};

	sleep 5;
	// hint "end flight wait ended";
	if ((alive _helo) and (count(crew _helo) == 0)) then {
		player sidechat format ["%1 has landed safely.", _callsign];
		hintsilent format ["%1 has landed safely.", _callsign];
		sleep 2;
		player sidechat format ["%1 is being rearmed/refueled at this time and will be avaiable soon.", _callsign];
		hintsilent format ["%1 is being rearmed/refueled at this time and will be avaiable soon.", _callsign];
		_helo setposASL getposASL _home;
		_helo setdir getdir _home;
		_helo setDamage 0;
		_helo setFuel 1;
		_mags = getArray (configFile>>"cfgVehicles">>typeOf _helo>>"Turrets">>"MainTurret">>"magazines");
		{_helo removeMagazine _x} forEach magazines _helo;
		{_helo addMagazine _x} forEach _mags;
	};

	// hint "deleting pilots and stuff";
	sleep 1.5;
	_pilot action ["engineOff", _helo];
	doGetOut [_pilot,_gunner];
	sleep 1;
	unassignVehicle _pilot;
	deleteVehicle _pilot;
	unassignVehicle _gunner;
	deleteVehicle _gunner;

	// this should reset the helo back in the correct direction after landing.
	// hint "resetting helo position";
	_spwndir = getdir _home;
	_helo setdir _spwndir;

	sleep RUM_AHEL_ReSupTime;
	player sidechat format ["%1 has been rearmed/refueled and is now available for service.", _helo];
	RUM_AHelAircraft = RUM_AHelAircraft + [_this];
	_helo setVariable ["RUM_inFlight", false, true];

if(true)exitwith{};